<script setup lang="ts">
import { ref } from 'vue'
import { getAssetsImge } from '/@/utils/getImge'

const searchQuery = ref('')
const cartCount = ref(0)

const navItems = [
  { name: 'Chat', path: '/chat', active: true },
  { name: 'Contact', path: '/contact' },
  { name: 'Settings', path: '/settings' }
]

// 添加 logo 路径
const logoPath = getAssetsImge('logo.png')
</script>

<template>
  <nav class="navbar">
    <div class="nav-container">
      <!-- Logo -->
      <div class="logo">
        <img :src="logoPath" alt="Logo" class="logo-img" />
        <a href="/" class="logo-text">Chat</a>
      </div>

      <!-- 主导航 -->
      <div class="nav-links">
        <template v-for="item in navItems" :key="item.name">
          <div class="nav-item" :class="{ active: item.active }">
            <a :href="item.path">{{ item.name }}</a>
          </div>
        </template>
      </div>

      <!-- 右侧操作区 -->
      <div class="nav-actions">
        <button class="action-btn" title="Search">
          <i class="fas fa-search"></i>
        </button>
        <button class="action-btn" title="Video Call">
          <i class="fas fa-video"></i>
        </button>
        <button class="action-btn" title="Voice Call">
          <i class="fas fa-phone"></i>
        </button>
        <button class="action-btn" title="Group">
          <i class="fas fa-users"></i>
        </button>
      </div>
    </div>
  </nav>
</template>

<style scoped>
.navbar {
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 64px;
}

.nav-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-img {
  height: 32px;
  width: auto;
}

.logo-text {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 32px;
}

.nav-item {
  position: relative;
  padding: 8px 0;
}

.nav-item a {
  color: #666;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-item.active a {
  color: #0084ff;
}

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: #0084ff;
  border-radius: 2px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: none;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.action-btn:hover {
  background-color: #f5f5f5;
  color: #333;
}

.action-btn i {
  font-size: 18px;
}

/* 特定图标的颜色 */
.action-btn .fa-video {
  color: #2196f3;
}

.action-btn .fa-phone {
  color: #4caf50;
}

.action-btn .fa-users {
  color: #ff9800;
}

/* 工具提示 */
.action-btn::after {
  content: attr(title);
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0,0,0,0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  z-index: 1000;
}

.action-btn:hover::after {
  opacity: 1;
  visibility: visible;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .nav-links {
    display: none;
  }
  
  .nav-container {
    padding: 0 16px;
  }
  
  .action-btn::after {
    display: none;
  }
}
</style>
